# -*-coding:utf-8 -*-
"""
专题报表-沪深股票-沪深港通-深股通十大活跃成交股
"""
from EmQuantAPI import *
import common.mainApi as mp
import common.handler_date_time as hd_dt
import common.handler_ctr_result as hd_cr
import common.dataFrame as df
import common.sql as db
import common.mainApi as ma
import config.base_info as bs

base_type = "ctr"
base_target = "target"
base_index = "ActiveStockTOP10SZInfo"

info_ = bs.INDEX_INFO.get(base_type).get(base_target).get(base_index)  # ->dict
param_code = info_.get("return_data")  # ->list
param_ = ",".join(param_code)
option_ = "period=1,TradeDate={0}"


def mainActiveStockTOP10SZInfo(tradeDate="2021-03-25"):

    data = c.ctr(base_index, param_, option_.format(tradeDate))

    return data


if __name__ == "__main__":
    mp.login()
    #startDate = "2019-09-01"
    #endDate = "2019-12-31"
    startDate = "2021-04-28"
    endDate = "2021-04-28"
    trade_date = hd_dt.getDateOfCycle(start_date=startDate, end_date=endDate)
    for i in trade_date:
        data = mainActiveStockTOP10SZInfo(tradeDate=i)
        hd_cr.ctr_result_handler(data_res=data, index_=base_index)
    mp.stop()
    db.dbcon_dispose()  # close-db
